home *** CD-ROM | disk | FTP | other *** search
- Path: tank.news.pipex.net!pipex!warwick!not-for-mail
- From: esuqf@csv.warwick.ac.uk (Praveen)
- Newsgroups: comp.lang.c++
- Subject: Class of incomplete type - HELP
- Date: 10 Mar 1996 21:15:21 -0000
- Organization: University of Warwick, Coventry, UK
- Message-ID: <4hvgp9$8jr@crocus.csv.warwick.ac.uk>
- NNTP-Posting-Host: crocus-fddi.csv.warwick.ac.uk
- Mime-Version: 1.0
- Content-Type: text/plain; charset=US-ASCII
- Content-Transfer-Encoding: 7bit
- X-Newsreader: TIN [version 1.2 PL2]
-
-
- Hi,
-
- I've got a problem for an assignment which consists of helping a user
- solve a single substitution cryptogram. I've spent ages trying to correct a
- compilation error. Could someone please help? Here's the situation:
-
-
- I've got three classes:
-
-
- class List {
-
- // Used to store the cryptogram in a linked list.
- // Works OK
-
- ..........
-
- }
-
-
- class alphabet {
-
- // Uses two arrays - one stores the ciphertext letters 'a' to 'z'
- // The other stores their assumed plaintext values, or a '*' if no value
- // has yet been deciphered by the program.
-
- public:
-
- char plain (char cipherin) {
-
- // Returns the assumed plaintext value of a given cipher letter by
- // looking up in the arrays
-
- }
-
- ..........
-
- }
-
-
- class Blackboard {
-
- // Used to store two linked lists with operations defined to modify them
-
-
- public:
-
- ..........
-
- Boolean isSolved() {
-
- // Returns True if cryptogram is solved, False otherwise.
-
- .........
- char cipherletter = current->letter // Character node of linked list
- if ( plain(cipherletter) == '*' )
- return False;
-
- .........
-
- }
-
- }
-
-
- PROBLEMS
- --------
-
- 1. I compile using: g++ list.C alphabet.C blackboard.C
-
- Error message:
- blackboard.C: In method `enum Boolean Blackboard::isSolved()':
- blackboard.C:70: warning: implicit declaration of function `int plain(...)'
- ^^^
- Strange Thing: The return type of function plain should be char. Or
- am I missing something??
-
-
- 2. I tried to inherit the alphabet class in the Blackboard class,
- thinking that the code would work if char plain(..) becomes a
- member function of Blackboard, I get the following:
-
- class Blackboard: public alphabet {
- ..............
- }
-
- blackboard.H:4: base class `alphabet' has incomplete type
-
- What does incomplete type mean?
- Has it got anything to do with constructors and destructors, which
- I have not included in my classes ?
-
-
- 3. Next, I thought that declaring an instance of alphabet and calling
- plain as follows would work:
-
- alphabet v;
- if ( v.plain(cipherletter) == '*' ) {
- ...........
- }
-
- Error messages:
- blackboard.C:8: aggregate `class alphabet v' has incomplete type and cannot
- be initialized
- blackboard.C: In method `enum Boolean Blackboard::isSolved()':
- blackboard.C:70: `cipherletter' undeclared (first use this function)
- blackboard.C:70: (Each undeclared identifier is reported only once
- blackboard.C:70: for each function it appears in.)
-
-
- I just can't understand what's going on. Any help would be appreciated.
- Thanks.
-
-
- --
- Praveen.
-